import { Request as request } from '@/utils/request'
import { PageParam } from '@/config/common'

export const getDicts = (pageParams: PageParam, data: any) => {
  return request({
    url: '/dict/list',
    method: 'post',
    params: pageParams,
    data
  })
}

export const getTotalDicts = () => {
  return request({
    url: '/dict/total-list',
    method: 'post'
  })
}

export const saveDict = (data: any) => {
  return request({
    url: '/dict/save',
    method: 'post',
    data
  })
}

export const removeDict = (id: string) => {
  return request({
    url: `/dict/delete-item/${id}`,
    method: 'delete'
  })
}

export const getDictItems = (pageParams: PageParam, data: any) => {
  return request({
    url: '/dict/items',
    method: 'post',
    params: pageParams,
    data
  })
}

export const getTotalDictItems = (dictCodes: string[]) => {
  return request({
    url: '/dict/total-items',
    method: 'post',
    data: {
      dictCodes
    }
  })
}

export const saveDictItem = (data: any) => {
  return request({
    url: '/dict/save-item',
    method: 'post',
    data
  })
}
